package lexico;

import java_cup.runtime.*;

/* Expand this into your solution for
project 2 */
public class lexi {
}

class CSXToken {

    int linenum;
    int colnum;

    CSXToken(int line, int col) {
        linenum = line;
        colnum = col;
    }
    ;
}

class CSXIntLitToken extends CSXToken {

    int intValue;

    CSXIntLitToken(int val, int line,
            int col) {
        super(line, col);
        intValue = val;
    }
    ;
}

class CSXIdentifierToken extends CSXToken {

    String identifierText;

    CSXIdentifierToken(String text, int line,
            int col) {
        super(line, col);
        identifierText = text;
    }
    ;
}

class CSXCharLitToken extends CSXToken {

    char charValue;

    CSXCharLitToken(char val, int line,
            int col) {
        super(line, col);
        charValue = val;
    }
    ;
}

class CSXStringLitToken extends CSXToken {

    String stringText;

    CSXStringLitToken(String text,
            int line, int col) {
        super(line, col);
        stringText = text;
    }
    ;
}

// This class is used to track line and column numbers
// Feel free to change to extend it
class Pos {

    static int linenum = 1;
    /* maintain this as line number current
    token was scanned on */
    static int colnum = 1;
    /* maintain this as column number
    current token began at */
    static int line = 1;
    /* maintain this as line number after
    scanning current token */
    static int col = 1;
    /* maintain this as column number
    after scanning current token */

    static void setpos() {
//set starting pos for current token
        linenum = line;
        colnum = col;
    }
}
/*
%%

Digit=[0-9]
// Tell JLex to have yylex() return a
Symbol, as JavaCUP will require
%type Symbol
// Tell JLex what to return when eof of
file is hit
%eofval{
return new Symbol(sym.EOF,
new CSXToken(0,0));
%

eofval}
%%
"+" {Pos.setpos(); Pos.col+=1;
return new Symbol(sym.PLUS,new CSXToken(Pos.linenum,Pos.colnum));
}

"!=" {Pos.setpos(); Pos.col+=2;
return new Symbol(sym.NOTEQ,new CSXToken(Pos.linenum,Pos.colnum));}

";" {Pos.setpos(); Pos.col+=1;
return new Symbol(sym.SEMI,new CSXToken(Pos.linenum,Pos.colnum));}

{Digit}+ {// This def doesn’t check
// for overflow
Pos.setpos();
Pos.col+= yytext().length();
return new Symbol(sym.INTLIT,new CSXIntLitToken( new Integer(yytext()).intValue(), Pos.linenum,Pos.colnum));}

\n {Pos.line +=1; Pos.col= 1;}

" " {Pos.col +=1;}
 * */